Html = {
	/**
	 * @param array|string url
	 * @param object params
	 * @return string
	 */
	normalizeUrl: function(url, params) {
		var res = '';
		if ('object' == typeof url) {
			res += '/?r=' + url;
		} else if ('string' == typeof url) {
			res += url;
		}
		if (params && ('object' == typeof params)) {
			var symbol = (res.indexOf('?') == -1) ? '?' : '&';
			res += symbol + decodeURIComponent($.param(url));
		}
		return res;
	},

	redirect: function(url) {
		url = this.normalizeUrl(url);
		window.location.href = url;
	}
}

function Pager(options){
	var _options = {
		gridId: null,
		selectedItems: null,
		urlDeleteItems: null
	};
	$.extend(_options, options);
	return {
		_gridId: _options.gridId,
		_selectedItems: _options.selectedItems,
		_urlDeleteItems: _options.urlDeleteItems,
		groupDelete: function() {
			if (confirm("Вы уверены, что хотите удалить отмеченные записи?")) {
				var selectedItemsArr = $.fn.yiiGridView.getSelection(this._gridId);
				if (selectedItemsArr.length >= 1) {
					var self = this;
					$.post(Html.normalizeUrl(this._urlDeleteItems), {'ids[]': selectedItemsArr},function(){
						$.fn.yiiGridView.update(self._gridId);
						$(self._selectedItems).val('');
					});
				}
			} else {
				$(this._selectedItems).val('');
			}
		},
		selectedItemsChange: function(e){
			var action = $(this._selectedItems).val();
			if ('delete' === action) {
				this.groupDelete();
			}
		},
		init: function(){
			var self = this;
			$(this._selectedItems).change(function(e){return self.selectedItemsChange(e)});
		}
	}
}